<?php 
import('@.Model.CommonModel');
class MemberModel extends CommonModel
{//类定义开始
	protected $_validate	 =	 array(
		array('username','require','用户名必须！'),
        array('username','','用户名已经存在',0,'unique','add'), 
		array('password','require','用户密码必须！'),
		array('password2','password','密码不一致！',0,'confirm'),
		array('email','email','Email格式不对！'),
        array('verify','require','验证码必须！'), 
        array('verify','CheckVerify','验证码错误',0,'callback'), 
		);

	protected $_auto	 =	 array(
		array('regtime','time','ADD','function'),
		array('lastregtime','time','ADD','function'),
		);

	//设定状态
	function setStatus($ids,$status='1') {
		$result = $this->setField('status',$status,"uid in ($ids)");
		if(false===$result){
			return false;
		}else{
			return true;
		}
	}

	//审核
	function check($ids,$status='1') {
		$result = $this->setField('ischeck',$status,"uid in ($ids)");
		if(false===$result){
			return false;
		}else{
			return true;
		}
	}

	//返回客户端IP和代理信息
	function getIP()
	{
		if (isset ($_SERVER['HTTP_X_FORWARDED_FOR']))
		{
			$currentIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
			$isagent = TRUE;
		}
		elseif (isset ($_SERVER['HTTP_CLIENT_IP']))
		{
			$currentIP = $_SERVER['HTTP_CLIENT_IP'];
			$isagent = TRUE;
		}
		else
		{
			$currentIP = $_SERVER['REMOTE_ADDR'];
			$isagent = FALSE;
		}
		$currentIP = addslashes(htmlspecialchars($currentIP));
		preg_match('/[\d\.]{7,15}/', $currentIP, $match);
		$currentIP = $match[0] ? $match[0] : FALSE;
		//return array($currentIP, $isagent);
		return $currentIP;
	}
}//类定义结束
?>